package com.echo.entity;

import java.util.Date;
import java.util.List;

/**
 * 文章实体类，对应数据库中的article表
 */
public class Article {
    private Integer id;          // 数据库主键（自增）
    private String title;        // 文章标题
    private String content;      // 文章内容
    private String htmlContent;  // 文章内容的HTML格式（用于显示）
    private String authorUsername;   // 作者用户名（冗余字段，方便展示,关联users表）
    private Integer viewCount;   // 浏览量
    private Integer status;      // 状态（1发布/0草稿/2下架）
    private Date createTime;     // 创建时间
    private Date updateTime;     // 更新时间
    private List<Category> categories; // 文章关联的分类列表

    // 无参构造函数
    public Article() {
    }

    // 全参构造函数
    public Article(Integer id, String title, String content, String htmlContent, String authorUsername, 
                   Integer viewCount, Integer status, Date createTime, Date updateTime) {
        this.id = id;
        this.title = title;
        this.content = content;
        this.htmlContent = htmlContent;
        this.authorUsername = authorUsername;
        this.viewCount = viewCount;
        this.status = status;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    // Getter和Setter方法
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getHtmlContent() {
        return htmlContent;
    }

    public void setHtmlContent(String htmlContent) {
        this.htmlContent = htmlContent;
    }

    public String getAuthorUsername() {
        return authorUsername;
    }

    public void setAuthorUsername(String authorUsername) {
        this.authorUsername = authorUsername;
    }

    public Integer getViewCount() {
        return viewCount;
    }

    public void setViewCount(Integer viewCount) {
        this.viewCount = viewCount;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<Category> getCategories() {
        return categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    // toString方法，用于调试
    @Override
    public String toString() {
        return "Article{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", authorUsername='" + authorUsername + '\'' +
                ", status=" + status +
                ", viewCount=" + viewCount +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}